import { useAuthStore } from '@/stores/auth';

/**
 * 验证是否有按钮权限
 * @param perms 权限标识
 * @returns {boolean}
 */
export function checkPerms(perms: string): boolean {
  const authStore = useAuthStore();
  const permsArray = authStore.perms;

  
  if(authStore.userInfo.izSuperAdmin){
    return true;
  }
  
  if (!permsArray || permsArray.length === 0) {
    return false;
  }
  
  return permsArray.includes(perms);
}

/**
 * Vue3 全局属性插件
 */
export default {
  install(app: any) {
    app.config.globalProperties.$perms = checkPerms;
  }
}; 